﻿// Accord Statistics Library
// The Accord.NET Framework
// http://accord-framework.net
//
// Copyright © César Souza, 2009-2013
// cesarsouza at gmail.com
//
//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public
//    License along with this library; if not, write to the Free Software
//    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//

namespace Accord.Statistics.Models.Markov.Hybrid
{
    using System;

    /// <summary>
    ///   Common interface for Hybrid Hidden Markov Models.
    /// </summary>
    /// 
    public interface IHybridMarkovModel
    {

        /// <summary>
        ///   Calculates the most likely sequence of hidden states
        ///   that produced the given observation sequence.
        /// </summary>
        /// <remarks>
        ///   Decoding problem. Given the HMM M = (A, B, pi) and  the observation sequence 
        ///   O = {o1,o2, ..., oK}, calculate the most likely sequence of hidden states Si
        ///   that produced this observation sequence O. This can be computed efficiently
        ///   using the Viterbi algorithm.
        /// </remarks>
        /// <param name="observations">
        ///   A sequence of observations.</param>
        /// <param name="logLikelihood">
        ///   The state optimized probability.</param>
        /// <returns>
        ///   The sequence of states that most likely produced the sequence.
        /// </returns>
        /// 
        int[] Decode(double[][] observations, out double logLikelihood);

        /// <summary>
        ///   Calculates the probability that this model has generated the given sequence.
        /// </summary>
        /// <remarks>
        ///   Evaluation problem. Given the HMM  M = (A, B, pi) and  the observation
        ///   sequence O = {o1, o2, ..., oK}, calculate the probability that model
        ///   M has generated sequence O. This can be computed efficiently using the
        ///   Forward algorithm. </remarks>
        /// <param name="observations">
        ///   A sequence of observations. </param>
        /// <returns>
        ///   The probability that the given sequence has been generated by this model.
        /// </returns>
        /// 
        double Evaluate(double[][] observations);

        /// <summary>
        ///   Gets the expected number of dimensions in each observation.
        /// </summary>
        /// 
        int Dimension { get; }

        /// <summary>
        ///   Gets the number of states of this model.
        /// </summary>
        /// 
        int States { get; }

        /// <summary>
        ///   Gets or sets a user-defined tag.
        /// </summary>
        /// 
        object Tag { get; set; }

    }

}
